package com.myl.admin;

import com.myl.core.utils.IpUtils;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;

@Slf4j
@ComponentScan({"com.myl.core", "com.myl.generator"})
@MapperScan(basePackages = {"com.myl.core.mapper"})
@SpringBootApplication
public class MylAdminApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext application = SpringApplication.run(MylAdminApplication.class, args);
        Environment env = application.getEnvironment();
        log.info("\n----------------------------------------------------------\n\t" +
                        "Application '{}' is running! Access URLs:\n\t" +
                        "Local: \t\thttp://127.0.0.1:{}\n\t" +
                        "External: \thttp://{}:{}\n\t" +
                        "Doc:   \thttp://{}:{}/swagger-ui.html\n" +
                        "----------------------------------------------------------",
                env.getProperty("myl.name"),
                env.getProperty("server.port"),
                IpUtils.getHostIp(),
                env.getProperty("server.port"),
                env.getProperty("server.address"),
                env.getProperty("server.port"));
    }

}
